//
//  BaseTableViewController.swift
//  我的微博
//
//  Created by 李献红 on 15/10/8.
//  Copyright © 2015年 cn.lixianhong. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate{

    ///  用户登录标记
    var userLogin = UserAccount.userLogin
    
    var visitorView: VisitorLoginView?
    
    override func loadView() {
        // 根据用户是否登录判断是否替换根视图
        userLogin ? super.loadView() : setupVisitorView()
    }

    
    ///  设置访客视图
    private func setupVisitorView() {
    
        visitorView = VisitorLoginView()
        visitorView?.delegate = self
        view = visitorView
        
        //设置状态栏
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        
        

    }
    
    
    //MARK: - 按钮的点击事件
    func visitorLoginViewWillLogin() {
        let nav = UINavigationController(rootViewController: OAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
    
        print("登录")
    }
    
    func visitorLoginViewWillRegister(){
    
        print("注册")
    }
}
